package cn.cocho.custom.yunCashierDf.log.service;

import cn.cocho.common.web.character.StringUtils;
import cn.cocho.common.web.jqgrid.JQGridPage;
import cn.cocho.common.web.jqgrid.JQGridUtils;
import cn.cocho.custom.yunCashierDf.log.domain.LogInfo;
import cn.cocho.dborm.core.Dborm;
import org.springframework.stereotype.Service;

/**
 * Created by WQJ on 2015/12/10.
 */
@Service("logInfoService")
public class LogInfoService {
    public JQGridPage getListByJQgrid(JQGridPage<LogInfo> pageJQGrid) {
        pageJQGrid = JQGridUtils.getListByJQgrid(pageJQGrid, LogInfo.class, "log_info");
        for (LogInfo logInfo : pageJQGrid.getDataRows()) {
            logInfo.init();
        }
        return pageJQGrid;
    }

    public void update(LogInfo logInfo) {
        Dborm.replace(logInfo);
    }

    public void add(LogInfo logInfo) {
        logInfo.setLogId(StringUtils.getUUID());
        Dborm.insert(logInfo);
    }

    public LogInfo getLogInfoById(String logId) {
        LogInfo logInfo = new LogInfo();
        logInfo.setLogId(logId);
        return Dborm.getEntityByExample(logInfo, true);
    }

    public boolean insertLogInfo(LogInfo logInfo) {
        logInfo.setLogId(StringUtils.getUUID());
        return Dborm.insert(logInfo);
    }


    public boolean replaceLogInfo(LogInfo logInfo) {
        logInfo.setLogId(logInfo.getLogId());
        return Dborm.replace(logInfo);
    }

}
